//
//  YYJLMessageDetailController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/4.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLMessageDetailController.h"
#import "YYJLMyMessageCell.h"
#import "YYJLSystemMessageCell.h"
@interface YYJLMessageDetailController ()<ChangeViewDelegate,UITableViewDataSource,UITableViewDelegate>
{
    int             page;
    NSMutableArray  *_mutArr;
    UITableView     *_tableView;
}
@end

@implementation YYJLMessageDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _mutArr = [[NSMutableArray alloc]init];
    
    [self setupNavBar];
    [self onCreateUI];
    
    [self onLoadNew];
}
#pragma mark - UI
- (void)setupNavBar {
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:@selector(navigationBackButton)];
    
}
-(void)onCreateUI{
    float heith = 0;
    heith = 80*PERCEN;

    
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-80*PER_HEIGHT+NAV_HEIGHT) style:UITableViewStylePlain];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_tableView];
}
-(void)navigationBackButton {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark--tableview
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.type==PersonalMessage) {
        YYJLMyMessageCell*cell1=[tableView dequeueReusableCellWithIdentifier:@"cell1"];
        if (!cell1) {
            cell1=[[YYJLMyMessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
        }
        return cell1;
    }else{
        YYJLSystemMessageCell*cell2=[tableView dequeueReusableCellWithIdentifier:@"cell2"];
        if (!cell2) {
            cell2=[[YYJLSystemMessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell2"];
        }
        return cell2;

    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 210*PER_HEIGHT;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
#pragma mark - Actions
#pragma mark - 选择器
- (void)onSelectItemForView:(ChangeView *)view withIndex:(NSInteger)selectIndex
{
    [self onLoadNew];
    if (selectIndex < 2) {
        self.type = (int)selectIndex;
        [self onLoadNew];
    }
}

-(void)onLoadNew{
    if (_type==PersonalMessage) {
        self.view.backgroundColor=[UIColor redColor];
    }else {
        self.view.backgroundColor=[UIColor cyanColor];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
